package mn.slide.petrovis;

import mn.slide.petrovis.contact.ContactTabGroupActivity;
import mn.slide.petrovis.news.NewsTabGroupActivity;
import mn.slide.petrovis.product.ProductTabGroupActivity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

public class PetrovisActivity extends TabActivity
{
	TabHost.TabSpec	spec;
	TabHost			tabHost;
	boolean			one;

	@Override
	public void onCreate( Bundle savedInstanceState )
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		tabHost = getTabHost();
		setTabs();
	}

	private void setTabs()
	{
		addTab(getString(R.string.home), R.drawable.tab_home, HomeTabGroupActivity.class);
		addTab(getString(R.string.news), R.drawable.tab_news, NewsTabGroupActivity.class);
		addTab(getString(R.string.my_card), R.drawable.tab_contact, CheckOurStoreActivity.class);
		addTab(getString(R.string.product), R.drawable.tab_product, ProductTabGroupActivity.class);
		addTab(getString(R.string.contact), R.drawable.tab_aboutourself, ContactTabGroupActivity.class);

	}

	private void addTab( String labelId , int drawableId , Class<?> c )
	{
		Intent intent = new Intent(this, c);
		spec = tabHost.newTabSpec(labelId);
		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
		TextView title = (TextView) tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
		icon.setImageResource(drawableId);
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
		tabHost.setCurrentTab(0);
	}

}